package dse.modules.eln;

import java.io.Serializable;

import dse.Node;

public class NodeWithCoordinates extends Node implements Serializable
{
	private static final long serialVersionUID = 1L;
	private double x;
	private double y;
	//private int ww;
	//private int wh;
	
	
	public NodeWithCoordinates (
			int id, 
			double x, 
			double y
			//, 
			//int worldWidth, 
			//int worldHeight
			)
	{
		super(id);
		this.x = x;
		this.y = y;
		//this.ww = worldWidth;
		//this.wh = worldHeight;
	}
	
	public double getX () { return x; }
	public double getY () { return y; }
	
	
	/**
	 * This method should be overriden if possible to provide a better distance
	 * calculation between nodes.
	 * 
	 * @param other
	 * @return
	 */
	public double distanceTo (Node other) {
		if (other instanceof NodeWithCoordinates) {
			NodeWithCoordinates n = (NodeWithCoordinates)other;
			return GeometryUtil.distance(x, y, n.x, n.y);
					//, ww, wh);
		}
		return super.distanceTo(other);
	}
}
